/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package orderProcessingProcess.callbackHandlerSecurity;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;

import orderProcessingProcess.util.AIC_log;

import org.apache.ws.security.WSPasswordCallback;

/**
 * 
 * @author dreni
 */
public class ServerPasswordCallbackHandler implements CallbackHandler {

	public void handle(Callback[] callbacks) throws SecurityException {

		String type = "BankingService";
		
		WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
		// boolean checkCredentials = false;

		if (pc.getIdentifier().equals("username")) {
			if (!pc.getPassword().equals("password")) {
				AIC_log.printerr(type, "Wrong password - access denied!");
				throw new SecurityException("WRONG CREDENTIALS");
			}
		}
		else
		{
			AIC_log.printerr(type, "Wrong username - access denied!");
			throw new SecurityException("WRONG CREDENTIALS");
		}
	}
}